Crate libafl_bolts

source ·
Expand description

Welcome to LibAFL_bolts

LibAFL_bolts: OS and Fuzzer Dev’s Libary Collection.

LibAFL logo

The libafl_bolts crate exposes a lot of low-level features of LibAFL for projects that are unrelated to fuzzing, or just fuzzers completely different to LibAFL. Some cross-platform things in bolts include (but are not limited to):

  • SerdeAnyMap: a map that stores and retrieves elements by type and is serializable and deserializable
  • ShMem: A cross-platform (Windows, Linux, Android, MacOS) shared memory implementation
  • LLMP: A fast, lock-free IPC mechanism via SharedMap
  • Core_affinity: A maintained version of core_affinity that can be used to get core information and bind processes to cores
  • Rands: Fast random number generators for fuzzing (like RomuRand)
  • MiniBSOD: get and print information about the current process state including important registers.
  • Tuples: Haskel-like compile-time tuple lists
  • Os: OS specific stuff like signal handling, windows exception handling, pipes, and helpers for fork

LibAFL_bolts is written and maintained by

Contributing

For bugs, feel free to open issues or contact us directly. Thank you for your support. <3

Even though we will gladly assist you in finishing up your PR, try to

  • keep all the crates compiling with stable rust (hide the eventual non-stable code under cfgs)
  • run cargo fmt on your code before pushing
  • check the output of cargo clippy --all or ./clippy.sh
  • run cargo build --no-default-features to check for no_std compatibility (and possibly add #[cfg(feature = "std")]) to hide parts of your code.

Some of the parts in this list may be hard, don’t be afraid to open a PR if you cannot fix them by yourself, so we can help.

License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies under more restrictive licenses, such as GPL or AGPL, can be enabled using the respective feature in each crate when it is present, such as the 'agpl' feature of the libafl crate.

Feature Flags

General Features

  • std (enabled by default) — Enables features that need rust’s std lib to work, like print, env, … support

  • alloc (enabled by default) — Enables all features that allocate in no_std

  • derive (enabled by default) — Provide the #[derive(SerdeAny)] macro.

  • rand_trait (enabled by default) — If set, libafl_bolt’s rand implementations will implement rand::Rng

  • python — Will build the pyo3 bindings

  • prelude (enabled by default) — Expose libafl::prelude for direct access to all types without additional use directives

  • cli — Expose libafl_bolts::cli for easy commandline parsing of common fuzzer settings

  • qemu_cli — Enables extra commandline flags for qemu-based fuzzers in cli

  • frida_cli — Enables extra commandline flags for frida-based fuzzers in cli

  • errors_backtrace — Stores the backtraces of all generated Errors. Good for debugging, but may come with a slight performance hit.

  • gzip (enabled by default) — Enables gzip compression in certain parts of the lib

  • xxh3 (enabled by default) — Replaces ahash with the potentially faster xxh3 in some parts of the lib. This yields a stable and fast hash, but may increase the resulting binary size slightly This also enables certain hashing and rand features in no_std no-alloc.

SerdeAny features

  • serdeany_autoreg (enabled by default) — Automatically register all #[derive(SerdeAny)] types at startup.

LLMP features

  • llmp_bind_public — If set, llmp will bind to 0.0.0.0, allowing cross-device communication. Binds to localhost by default.

  • llmp_compression (enabled by default) — Enables llmp compression using GZip

  • llmp_debug — Enables debug output for LLMP (also needs a logger installed)

  • llmp_small_maps (enabled by default) — Reduces the initial map size for llmp

Modules

  • Poor-rust-man’s downcasts to have AnyMap
  • The purpose of this module is to alleviate imports of the bolts by adding a glob import.
  • Based on https://github.com/alecmocatta/build_id (C) Alec Mocatta alec@mocatta.net under license MIT or Apache 2
  • A one-size-fits-most approach to defining runtime behavior of LibAFL fuzzers
  • Compression of events passed between a broker and clients. Currently we use the gzip compression algorithm for its fast decompression performance.
  • This crate manages CPU affinities.
  • Architecture agnostic processor features
  • LibAFL functionality for filesystem interaction
  • launcherDeprecated
    Dummy module informing potential users that the launcher module has moved out of libafl_bolts into libafl::events::launcher.
  • A library for low level message passing
  • Math-related functions that we commonly (or at least sometimes) need
  • Implements a mini-bsod generator. It dumps all important registers and prints a stacktrace. You may use the crate::os::unix_signals::ucontext function to get a ucontext_t.
  • Operating System specific abstractions
  • Wrappers that abstracts references (or pointers) and owned data accesses.
  • The purpose of this module is to alleviate imports of many components by adding a glob import.
  • The random number generators of LibAFL
  • Poor-rust-man’s downcasts for stuff we send over the wire (or shared maps)
  • A generic shared memory region to be used by any functions (queues or feedbacks too.)
  • Stores and restores state when a client needs to relaunch. Uses a ShMem up to a threshold, then write to disk.
  • Compiletime lists/tuples used throughout the LibAFL universe

Macros

Structs

Enums

  • Main error struct for LibAFL

Statics

Traits

  • Create an Iterator from a reference
  • Create an Iterator from a mutable reference
  • Can be converted to a mutable slice
  • Can be converted to a slice
  • Has a length field
  • Has a ref count
  • Trait to convert into an Owned type
  • We need fixed names for many parts of this lib.
  • Trait to truncate slices and maps to a new size

Functions

Type Aliases

Derive Macros

  • Derive macro to implement SerdeAny, to use a type in a SerdeAnyMap